<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head id="Head1">
<title>无标题页</title>
<link href="../css/uploadify.css" type="text/css" rel="stylesheet" />

<script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>

<script type="text/javascript" src="../js/swfobject.js"></script>

<script type="text/javascript" src="../js/jquery.uploadify.v2.1.4.min.js"></script>

<script type="text/javascript">
	$(document)
			.ready(
					function() {
						$('#file_upload')
								.uploadify(
										{
											'uploader' : 'uploadify.swf',
											'script' : 'upload.aspx?jx=bj',
											'cancelImg' : 'cancel.png',
											'buttonImg' : 'add_photo.png',
											'fileExt' : '*.jpg;*.gif;*.png;*.jpeg',
											'fileDesc' : '请选择jpg gif png jpeg文件',
											'sizeLimit' : 102400,
											'queueSizeLimit' : 8,
											'width' : 100,
											'height' : 25,
											'multi' : true,
											'auto' : true,
											'onQueueFull' : function(event,
													queueSizeLimit) {
												return false;
											},
											'onSelectOnce' : function(event,
													data) {
												var f_img = $(
														window.parent.document)
														.find("#ClassSImg_hf")
														.val().split(';');
												if (f_img[0] != null
														&& f_img[0].length > 0) {
													if ((8 - (f_img.length - 1)) < data.fileCount) {
														$("#file_upload")
																.uploadifyClearQueue();
													}
												} else {
												}
											},
											'onComplete' : function(event, ID,
													fileObj, response, data) {
												if (response != null) {
													var url = response;
													var str;
													str = "";

													str += "<div id='d1' class='item_border' name="
															+ url.replace(";",
																	"")
															+ "><span class='item'><img width=\"80\" height=\"60\" src='http://pic6.fenlei168.com/"
															+ url.replace(";",
																	"")
															+ "'/></span><a class='delete'  href='javascript:void(0);' onClick=\"del('"
															+ url.replace(";",
																	"")
															+ "')\"></a></div>";
													$("#img1").append(str);
													$(window.parent.document)
															.find(
																	"#ClassSImg_hf")
															.val(
																	$(
																			window.parent.document)
																			.find(
																					"#ClassSImg_hf")
																			.val()
																			+ response);
													$("#yc").text("");
													$("#yc").text("您还可以上传");
													$("#count_lab")
															.text(
																	$(
																			"#count_lab")
																			.text() - 1);
												}
											}
										});
					});
	function del(url) {
		htmlobj = $.ajax({
			url : "/uploadify/Ajax.aspx?type=1&url=" + url,
			async : false
		});
		var return_num = htmlobj.responseText;
		if (return_num == "1") {
			$("div[name=" + url + "]").remove();
			$("#count_lab").text(parseFloat($("#count_lab").text()) + 1);
			var f_img = $(window.parent.document).find("#ClassSImg_hf").val()
					.split(';');
			if (f_img[0] != null && f_img[0].length > 0) {
				var _rep_url = "";
				var _rep_old_url = $.grep(f_img, function(n, i) {
					return n != url;
				});
				if (_rep_old_url.length == 1) {
					$(window.parent.document).find("#ClassSImg_hf").val("");
				} else {
					$.each(_rep_old_url, function(i, n) {
						_rep_url += n + ";"
					});
					$(window.parent.document).find("#ClassSImg_hf").val(
							_rep_url.substring(0, _rep_url.length - 1));
				}
			}
		}

	}

	function delupd(url) {
		$("div[name=" + url + "]").remove();
		$("#count_lab").text(parseFloat($("#count_lab").text()) + 1);
		var f_img = $(window.parent.document).find("#ClassSImg_hf").val()
				.split(';');
		if (f_img[0] != null && f_img[0].length > 0) {
			//alert( $(window.parent.document).find("#Ad_PicUrl").val());
			var _rep_url = "";
			var _rep_old_url = $.grep(f_img, function(n, i) {
				return n != url;
			});
			if (_rep_old_url.length == 1) {
				$(window.parent.document).find("#ClassSImg_hf").val("");
			} else {
				$.each(_rep_old_url, function(i, n) {
					_rep_url += n + ";"
				});
				$(window.parent.document).find("#ClassSImg_hf").val(
						_rep_url.substring(0, _rep_url.length - 1));
			}
		}
	}
</script>

</head>
<body>
	<div id="img1"
		style="padding-bottom: 10px; float: left; display: block;"></div>
	<div style="clear: left; float: none; height: 40px;">
		<span style="float: left;"> <input id="file_upload"
			name="file_upload" type="file" /></span><span
			style="float: left; color: #333; font-size: 12px; line-height: 30px;"
			id="sm"><span id="yc">按住 “ctrl” 键可一次选择多张图片上传，多于8张将取 前</span><b>&nbsp<span
				id="count_lab">8</span></b>&nbsp张</span>
	</div>
</body>
</html>